/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package operators;

import lab4.WaterCupState;
import templates.Operator;

/**
 *
 * @author morar.ciprian
 */
public  class Empty1to2 implements Operator <WaterCupState>{

    public boolean available(WaterCupState t) {
        if ( t.getCapacity1() > 0 && t.getCapacity2()<4)
        return true;
        else return false;
    }

public WaterCupState execute(WaterCupState W) {
  WaterCupState t = W;
int cantitateCeTrebuieTransferata=4- t.getCapacity2();
int cantitateTransferata;
if(cantitateCeTrebuieTransferata < t.getCapacity1())
cantitateTransferata= cantitateCeTrebuieTransferata;
else
cantitateTransferata=t.getCapacity1();
t.setCapacity1(t.getCapacity1()-cantitateTransferata);
t.setCapacity2(t.getCapacity2()+cantitateTransferata);
return t;
    }

    public int getOperatorNumber() {
        return 5;
    }

}
